package woaini.wind.bot.rasa.init;

import woaini.wind.bot.rasa.base.Action;
import woaini.wind.bot.rasa.base.ActionExecutor;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;
import woaini.wind.bot.core.boot.ApplicationStartupCompleted;


/**
 * 加载自定义动作相关
 * @see  RasaActionInit
 * @author yefeng
 * {@date 2024-10-29 17:46:53}
 */@Component
public class RasaActionInit implements ApplicationStartupCompleted {

  @Resource
  private ConfigurableListableBeanFactory beanFactory;

  @Resource
  private ActionExecutor actionExecutor;

  @Override
  public void onInit() {
    beanFactory.getBeansOfType(Action.class).values().forEach(
      action -> actionExecutor.registerAction(action)
    );
  }
}
